import { CopyInfoPanelBase } from "../copy/CopyInfoPanelBase";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { MemberRenderer } from "./MemberRenderer";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { SChaosFightBattleInfo } from "../../../../Message/Public/SChaosFightBattleInfo";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { SecTimer } from "../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../com/gengine/core/frame/TimerType";
import { RemainTimeTool } from "../award/RemainTimeTool";
import { GTileList } from "../../../../com/mui/controls/GTileList";
type int = number;
//class HeroBattleInfoPanel
    
    export  class HeroBattleInfoPanel extends CopyInfoPanelBase
    {
        constructor(arg1: string="MagicTowerInfoButtonBg")
        {
            super(arg1);
            this.title = Language.getString(200209);
            this.mouseEnabled = false;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            _bg.height = 270;
            this._processTxt = ObjCreate.createTextField(Language.getString(200202), 20, 25, 300, 20, _bodySp, null, true, false);
            this._memberList = ObjCreate.createTileList(20, 60, 220, 180, _bodySp);
            this._memberList.setStyle("cellRenderer", MemberRenderer);
            this._memberList.scrollPolicy = ScrollPolicy.OFF;
            this._memberList.columnWidth = 200;
            this._memberList.rowHeight = 25;
            this._eliteBossTime = ObjCreate.createTextField("", 20, 220, 300, 20, _bodySp);
            this._lordMonsterTime = ObjCreate.createTextField("", 20, 240, 300, 20, _bodySp);
            return;
        }

        public updateInfo(arg1: SChaosFightBattleInfo): void
        {
            if (!arg1) 
            {
                return;
            }
            var loc1=arg1.info;
            var loc2=loc1.length;
            this._endCountDown = arg1.battleLeftTime;
            var loc3=0;
            while (loc3 < 6 - loc2) 
            {
                loc1.push(loc3);
                ++loc3;
            }
            this._memberList.dataProvider = new DataProvider(loc1);
            this._memberList.drawNow();
            if (this._endCountDown == 0) 
            {
                this._processTxt.htmlText = Language.getString(200202);
                this._eliteBossTime.htmlText = Language.getStringByParam(200204, Language.getString(200208));
                this._lordMonsterTime.htmlText = Language.getStringByParam(200205, Language.getString(200208));
                return;
            }
            this._eliteTime = arg1.eliteRefreshTime;
            this._lordTime = arg1.lordRefreshTime;
            this.startTimerCount();
            return;
        }

        /* internal  */startTimerCount(): void
        {
            if (!this._timer) 
            {
                this._timer = new SecTimer();
                this._timer.addListener(TimerType.ENTERFRAME, this.onTimerHandler);
                this._timer.start();
            }
            return;
        }

        /* internal  */onTimerHandler(arg1: SecTimer): void
        {
            if (this._endCountDown > 0) 
            {
                var loc1;
                var loc2=((loc1 = this)._endCountDown - 1);
                loc1._endCountDown = loc2;
            }
            else 
            {
                this.clear();
                return;
            }
            if (this._eliteTime > 0) 
            {
                loc2 = ((loc1 = this)._eliteTime - 1);
                loc1._eliteTime = loc2;
                this._eliteBossTime.htmlText = Language.getStringByParam(200204, RemainTimeTool.getRemainTimeBySeconds(this._eliteTime));
            }
            else 
            {
                this._eliteBossTime.htmlText = Language.getStringByParam(200204, Language.getString(200207));
            }
            if (this._lordTime > 0) 
            {
                loc2 = ((loc1 = this)._lordTime - 1);
                loc1._lordTime = loc2;
                this._lordMonsterTime.htmlText = Language.getStringByParam(200205, RemainTimeTool.getRemainTimeBySeconds(this._lordTime));
            }
            else 
            {
                this._lordMonsterTime.htmlText = Language.getStringByParam(200205, Language.getString(200207));
            }
            this._processTxt.htmlText = Language.getStringByParam(200203, RemainTimeTool.getRemainTimeBySeconds(this._endCountDown, true, true));
            return;
        }

        public clear(): void
        {
            if (this._timer) 
            {
                this._timer.stop();
                this._timer.dispose();
                this._timer = null;
            }
            this._endCountDown = 0;
            this._processTxt.htmlText = Language.getString(200202);
            this._eliteBossTime.htmlText = Language.getStringByParam(200204, Language.getString(200208));
            this._lordMonsterTime.htmlText = Language.getStringByParam(200205, Language.getString(200208));
            return;
        }

        /* internal */ /* var */_processTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_memberList: GTileList;

        /* internal */ /* var */_eliteBossTime: Object /* flash.text.TextField */;

        /* internal */ /* var */_lordMonsterTime: Object /* flash.text.TextField */;

        /* internal */ /* var */_eliteTime: int;

        /* internal */ /* var */_lordTime: int;

        /* internal */ /* var */_endCountDown: int;

        /* internal */ /* var */_dp: DataProvider;

        /* internal */ /* var */_timer: SecTimer;
    }
